//
//  RBShopApplyAgreeVC.m
//  zhongzhenglu
//
//  Created by 马军凯 on 2023/4/27.
//

#import "RBShopApplyAgreeVC.h"
#import <WebKit/WebKit.h>
#import "RBShopApplyAgreeResponse.h"

@interface RBShopApplyAgreeVC ()
@property(nonatomic, strong)WKWebView *webview;
@property (nonatomic, strong) RBShopApplyAgreeResponse *response;

@end

@implementation RBShopApplyAgreeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setup];
    [self getData];
}
#pragma mark - Private

- (void)setup
{
    self.view.backgroundColor = UIColor.whiteColor;
    self.title = @"商家入驻协议";
}

- (void)fillData
{
    NSString *newHtmlString = [NSString stringWithFormat:@"<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'><meta name='apple-mobile-web-app-capable' content='yes'><meta name='apple-mobile-web-app-status-bar-style' content='black'><meta name='format-detection' content='telephone=no'><script>function show(s){document.location = '%@'+s;}</script><style type='text/css'>img{width:100%%}</style>%@", @"rb_pic_jump", self.response.data];
    [self.webview loadHTMLString:newHtmlString baseURL:nil];
}

#pragma mark - Network

- (void)getData
{
    MJWeakSelf;
    [self viewLoadDataWithParam:^(NSMutableDictionary *dicM) {
    } path:@"han_article_ruzhu" post:YES log:YES responseClass:RBShopApplyAgreeResponse.class desView:self.view showHud:YES showPlaceHolder:YES sucBlock:^(RBShopApplyAgreeResponse *data) {
        weakSelf.response = data;
        [weakSelf fillData];
    } failBlock:^(id data) {
        
    } reloadBlock:^{
        [weakSelf getData];
    }];
}


- (WKWebView *)webview
{
    if (!_webview)
    {
        self.webview = ({
            WKWebViewConfiguration *configuration = [WKWebViewConfiguration new];
            WKWebView *view = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
            view.backgroundColor = [UIColor whiteColor];
            view.allowsBackForwardNavigationGestures = NO;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            view;
        });
    }
    return _webview;
}


@end
